#!/usr/bin/python
# Filename: 05.py
import urllib, re
def next_nothing(url):
	info = urllib.urlopen(url).read()
	m = re.search('and the next nothing is ([0-9]+)$', info)
	if m : return m.group(1)
	print info

url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=%s'
nothing  = 12345
while True:
	nothing = next_nothing(url %nothing)
	if not nothing:break
	print nothing
# 44827
# 45439
# .
# .
# 3875
# 16044
# Yes. Divide by two and keep going.
nothing = 16044/2
while True:
	nothing = next_nothing(url %nothing)
	if not nothing:break
	print nothing
# 6711
# 2795
# .
# .
# 66831
# peak.html